<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page
	errorPage="../include/eproErrorPage.jsp"
	contentType="text/html; charset=windows-874"
	import=	"com.epro.standard.frontend.util.FileInfoUtil,
            com.epro.standard.usermenu.UserAccountVO,
            com.epro.standard.frontend.util.ShowData,java.util.Vector,
            com.epro.standard.usermenu.manage.*,
            java.text.SimpleDateFormat,
            com.softplus.carrefour.hd.bltier.entity.UserLevel,
            com.softplus.carrefour.hd.bltier.entity.CfhdCaseHead,
            com.softplus.carrefour.hd.bltier.admin.RoutePathManage,
            com.softplus.carrefour.hd.CFHDSystem" %>

<HTML xmlns:epro>
<%@ taglib uri="/WEB-INF/HeadTag.tld" prefix="head"%>
<%@ taglib uri="/WEB-INF/ToolbarTag.tld" prefix="toolbar"%>
<%@ taglib uri="/WEB-INF/ListboxTag.tld" prefix="listbox"%>
<%@ taglib uri="/WEB-INF/CheckboxTag.tld" prefix="CheckboxTag"%>
<%@ taglib uri="/WEB-INF/RadioButtonTag.tld" prefix="radioButton"%>
<%@ taglib uri="/WEB-INF/TextfieldTag.tld" prefix="textfield"%>

<head:Head
	author="Dee"
	title="Routing Setup : Add New"
	import="textfield,toolbar,listbox,button,radio"
	jsFile="../script/imgProp.js,../script/Alert.js,../script/checkValidData.js"
	styleFile ="../theme/defaultTheme.css"></head:Head>
<%
	com.epro.standard.frontend.util.EproServletUtil servletUtil = new com.epro.standard.frontend.util.EproServletUtil(request) ;
	String uid = request.getParameter("uid")== null?"":request.getParameter("uid");
	String caseType = request.getParameter("caseType")== null?"CaseType":request.getParameter("caseType");

        System.out.println("/*****************1******************caseType==="+caseType);
	String  closeIframe = request.getParameter("closeIframe") == null ? "" : request.getParameter("closeIframe");

        System.out.println("/***********************************In Copy Page=closeIframe==="+closeIframe);

 	if(closeIframe.equals("true"))
 	{
 		out.print("<script>");
 		out.print("dialogArguments.location.href=\"CFHDADMT03.jsp?caseType="+caseType+"&uid="+uid+"\";");
 		out.print("window.close();");
 		out.print("</script>");
 	}

	String listBoxWidth = "315" ;
	String action = "insert";
	String linkParameter	= "?";
	String insert = "../servlet/com.softplus.carrefour.hd.frontend.servlet.administration.CFHDAD03"+linkParameter;
	// list box of CaseType
	int caseTypeSelect = 1;

        System.out.println("***********caseType========="+caseType);
	//String caseTypeData[] = {"","P1","P2","P3"};
	//String caseTypeLabel[] = {"","User Question(P1)","Problem Report(P2)","Change Request(P3)"};

	String caseTypeData[] = {"",CfhdCaseHead.CASE_USER_QUESTION,CfhdCaseHead.CASE_PROBLEM_REPORT,CfhdCaseHead.CASE_CHANGE_REQUEST};
	String caseTypeLabel[] = {"",CfhdCaseHead.getStatusDesc(CfhdCaseHead.CASE_USER_QUESTION),CfhdCaseHead.getStatusDesc(CfhdCaseHead.CASE_PROBLEM_REPORT),CfhdCaseHead.getStatusDesc(CfhdCaseHead.CASE_CHANGE_REQUEST)};

	if(caseType.equals("P1")) caseTypeSelect = 2;
	else if(caseType.equals("P2")) caseTypeSelect = 3;
	else if(caseType.equals("P3")) caseTypeSelect = 4;
	// list box of From User Level
	int fromSelect = 1;
	String fromUserType = request.getParameter("fromUserType")== null?"":servletUtil.getRequestValue("fromUserType");

        System.out.println("***********fromUserType========="+fromUserType);
	String fromData[] = {"",UserLevel.LEVEL_1_COUNTRY_HELPDESK,UserLevel.LEVEL_2_COUNTRY_APPLICATION_TEAM_BACK_OFFICE,UserLevel.LEVEL_2_AMS_ZONE_ASIA,UserLevel.LEVEL_3_AMS_BANGKOK,UserLevel.PRODUCTION_STAFF};
	String fromLabel[] = {"",UserLevel.getLevelName(UserLevel.LEVEL_1_COUNTRY_HELPDESK),UserLevel.getLevelName(UserLevel.LEVEL_2_COUNTRY_APPLICATION_TEAM_BACK_OFFICE),UserLevel.getLevelName(UserLevel.LEVEL_2_AMS_ZONE_ASIA),UserLevel.getLevelName(UserLevel.LEVEL_3_AMS_BANGKOK),UserLevel.getLevelName(UserLevel.PRODUCTION_STAFF)};

	if(fromUserType.equals("L1C")) fromSelect = 2;
	else if(fromUserType.equals("L2C")) fromSelect = 3;
	else if(fromUserType.equals("L2Z")) fromSelect = 4;
	else if(fromUserType.equals("L3BKK")) fromSelect = 5;
	else if(fromUserType.equals("PROD")) fromSelect = 6;
	// list box of To User Level


	RoutePathManage routePathManage = (RoutePathManage)CFHDSystem.getControlClass("ROUTE_PATH");
        Vector dataVector = new Vector();
        System.out.println("/////////////////////>>>>>>>>>>>>>>  =  " +caseType );
        System.out.println("/////////////////////>>>>>>>>>>>>>>  =  " +fromUserType );
        dataVector  =  routePathManage.getToUserLevelForCase(caseType,fromUserType);
	String[] toData = new String[dataVector.size()+1];
	String[] toLabel = new String[dataVector.size()+1];
	toData[0] = "";
	toLabel[0] = "";
	for(int i=0; i< dataVector.size(); i++)
    {
//     System.out.println("/////////////////////dataVector =" +(String)dataVector.elementAt(i));
      toData[i+1]  =   (String)dataVector.elementAt(i);
      toLabel[i+1] =	UserLevel.getLevelName(toData[i+1]);
//      System.out.println("/////////////////////toData[i+1]  =" +toData[i+1] );
//      System.out.println("/////////////////////toLabel[i+1]  =" +toLabel[i+1] );
    }
	int toSelect = 1;
	String toUserType = request.getParameter("toUserType")== null?"":servletUtil.getRequestValue("toUserType");

	if(toUserType.equals("L1C")) toSelect = 2;
	else if(toUserType.equals("L2C")) toSelect = 3;
	else if(toUserType.equals("L2Z")) toSelect = 4;
	else if(toUserType.equals("L3BKK")) toSelect = 5;
	else if(toUserType.equals("PROD")) toSelect = 6;

	// list box of Hours or Minutes
	String listboxHours_Data[]    = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",};
    String listboxHours_Label[]   = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23",};
    String listboxMinutes_Data[]  = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
    String listboxMinutes_Label[] = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};

	//int indexUnattHours = request.getParameter("unattendedHours")== null?0:Integer.parseInt(servletUtil.getRequestValue("unattendedHours")) ;
	String stUnattHours = request.getParameter("unattendedHours")== null?"00":servletUtil.getRequestValue("unattendedHours") ;
	int indexUnattMinutes = request.getParameter("unattendedMinutes")== null?0:Integer.parseInt(servletUtil.getRequestValue("unattendedMinutes"));
	//int indexAutoEHours = request.getParameter("autoEHours")== null?0:Integer.parseInt(servletUtil.getRequestValue("autoEHours"));
	String stAutoEHours = request.getParameter("autoEHours")== null?"00":servletUtil.getRequestValue("autoEHours");
	int indexAutoEMinutes = request.getParameter("autoEMinutes")== null?0:Integer.parseInt(servletUtil.getRequestValue("autoEMinutes"));
	String chkRoute = request.getParameter("routeRadio")== null?"E":servletUtil.getRequestValue("routeRadio");
	String chkDef = request.getParameter("defaultRadio")== null?"N":servletUtil.getRequestValue("defaultRadio");

	//********Route Direction*****
		String chkEscalate 	= "";
		String chkReturn	= "";
		if(chkRoute.equals("E"))
		{
			chkEscalate= "checked";
		}else {
					chkReturn= "checked";
			  }
		System.out.println("***********chkRoute========="+chkRoute+"///////chkEscalate===="+chkEscalate+"//////chkReturn===="+chkReturn);
	//*******Default Route*********
		String chkYes 	= "";
		String chkNo	= "";
		if(chkDef.equals("Y"))
		{
			chkYes= "checked";
		}else{
					chkNo= "checked";
			 }
	System.out.println("***********chkDef========="+chkDef+"///////////="+chkYes+"///////////="+chkNo);
%>
<SCRIPT language="javascript">
function submitForm()
{
	if( isNull(frm.caseType,"CaseType")  &&
		isNull(frm.fromUserType,"From User Level")&&
		isNull(frm.toUserType,"To User Level"))
		{
			if (showOConfirmDialog("Confirm","Do you want to save?","OK","Cancel") == 1)
			{
				if(frm.unattendedHours.value == "") frm.unattendedHours.value = "0";
				if(frm.autoEHours.value == "") frm.autoEHours.value = "0";
					frm.submit();

			}

		}
}
function clkChangeData()
{
	if(frm.fromUserType.value != "")
	{
		frm.toUserType.disabled = false;
		frm.toUserType.value = "";
		var route = "E";
		var defaultRoute = "N";

		if(frm.routeRadio[1].checked)
			route = "R";
		if(frm.defaultRadio[0].checked)
			defaultRoute = "Y";
		/*frm.toUserType.value = "";
		frm.unattendedHours.value = "00";
		frm.autoEHours.value ="00";*/

		document.location.href("CFHDADIN03.jsp?caseType="+'<%=caseType%>'+"&uid="+'<%=uid%>'
	+"&fromUserType="+frm.fromUserType.value+"&toUserType="+frm.toUserType.value
	+"&unattendedHours="+frm.unattendedHours.value+"&unattendedMinutes="+frm.unattendedMinutes.value
	+"&autoEHours="+frm.autoEHours.value+"&autoEMinutes="+frm.autoEMinutes.value
	+"&routeRadio="+route+"&defaultRadio="+defaultRoute);
	}else
		frm.toUserType.disabled = true;
}
function setData()
{
	if(frm.fromUserType.value == "")
		frm.toUserType.disabled = true;
}
function Clear()
{
	if (showOConfirmDialog("Confirm","Do you want to reset?","OK","Cancel") == 1)
	{
		frm.fromUserType.children[0].selected = true;
		frm.toUserType.children[0].selected = true;
		frm.unattendedHours.value = "00";
		frm.unattendedMinutes.children[0].selected = true;
		frm.autoEHours.value = "00";
		frm.autoEMinutes.children[0].selected = true;
		frm.routeRadio[0].checked = true;
		frm.defaultRadio[1].checked = true;
		frm.toUserType.disabled = true;
	}
//	frm.reset();

}
function Back()
{
	if (showOConfirmDialog("Confirm","Do you want to back?","OK","Cancel") == 1)
    {
		window.close();
	}
}
function noInteger()
{
	var u = event.srcElement.value ;
	u = u.substring(0,1);
	if(u == '-')
		event.srcElement.value = "";
		//showOWarningDialog("warning", "Data in field is not integer", "OK");
}

</SCRIPT>
<BODY onload="setData();">
<DIV style="width:100%;height:90%;margin:5px" class="modalBg">
<FORM name="frm" action="<%=insert%>" method="post" onsubmit="submitForm();return false;">
	<INPUT type="hidden" name="action" value="<%=action%>">
	<INPUT type="hidden" name="hCaseType" value="<%=caseType%>">
	<INPUT type="hidden" name="uid" value="<%=uid%>">
	<TABLE align="center" width="100%" border="0">
	<TBODY>
		<TR>
			<TD colspan="3">
    			<IMG alt="Save" src="../images/icon/toolbar/nSave.gif" onmouseover="this.src='../images/icon/toolbar/oSave.gif'" onmouseout="this.src='../images/icon/toolbar/nSave.gif'" style="cursor:hand" onclick="submitForm();">
            	<IMG alt="Clear" src="../images/icon/toolbar/nClear.gif" onmouseover="this.src='../images/icon/toolbar/oClear.gif'" onmouseout="this.src='../images/icon/toolbar/nClear.gif'" style="cursor:hand" onclick="Clear();">
            	<IMG alt="Back" src="../images/icon/toolbar/nExit.gif" onmouseover="this.src='../images/icon/toolbar/oExit.gif'" onmouseout="this.src='../images/icon/toolbar/nExit.gif'" style="cursor:hand" onclick="Back();">
        	</TD>
		</TR>
		<TR>
			<TD  align="right" colspan="3"><FONT class="titleFont" color="red">*required field</FONT></TD>
		</TR>
		<TR>
			<TD width="40%" align="right" valign="top" class="titleFont">Case Type : </TD>
        	<TD width="5"></TD>
        	<TD class="dataDetailPK"><textfield:textfield  name="caseType" width="315" readonly="yes" value="<%=CfhdCaseHead.getStatusDesc(caseType)%>"></textfield:textfield></TD>
        </TR>
		<TR>
			<TD align="right" valign="top" class="titleFont"><FONT class="titleFont" color="red">*</FONT>From User Level : </TD>
        	<TD width="5"></TD>
        	<TD class="dataDetailPK"><listbox:listbox name="fromUserType" data="<%=fromData%>" label="<%=fromLabel%>" selectedIndex="<%=fromSelect%>" width="<%=listBoxWidth%>" onchange="clkChangeData();"></listbox:listbox></TD>

		</TR>
		<TR>
			<TD align="right" valign="top" class="titleFont"><FONT class="titleFont" color="red">*</FONT>To User Level : </TD>
        	<TD width="5"></TD>
        	<TD class="dataDetailPK"><listbox:listbox name="toUserType" data="<%=toData%>" label="<%=toLabel%>" selectedIndex="<%=toSelect%>" width="<%=listBoxWidth%>" ></listbox:listbox></TD>
        </TR>
		<TR>
			<TD align="right" valign="top" class="titleFont">Unattended Period :</TD>
			<TD width="5"></TD>
			<TD class="dataDetailPK" colspan="2"><textfield:textfield onkeyup="noInteger();" dataType="integer" maxLength="7" name="unattendedHours" width="155" value="<%=stUnattHours%>"></textfield:textfield>
				<listbox:listbox name="unattendedMinutes" data="<%=listboxMinutes_Data%>" label="<%=listboxMinutes_Label%>" selectedIndex="<%=indexUnattMinutes+1%>" width="155"></listbox:listbox></TD>
		</TR>
		<TR>
			<TD align="right" valign="top" class="titleFont">Auto Escalate Period :</TD>
			<TD width="5"></TD>
			<TD class="dataDetailPK" colspan="2"><textfield:textfield onkeyup="noInteger();" dataType="integer" name="autoEHours" maxLength="7" width="155" value="<%=stAutoEHours%>"></textfield:textfield>
			<listbox:listbox name="autoEMinutes" data="<%=listboxMinutes_Data%>" label="<%=listboxMinutes_Label%>" selectedIndex="<%=indexAutoEMinutes+1%>" width="155"></listbox:listbox></TD>
		</TR>
		<TR>
			<TD align="right" valign="top" class="titleFont">Route Direction :</TD>
			<TD width="5"></TD>
			<TD class="titleFontleft" colspan="2"><INPUT type="radio" name="routeRadio"  value="E" id="routeRadio" checked="checked" <%=chkEscalate%>>Escalate
			 <INPUT type="radio" name="routeRadio" id="routeRadio" value="R" <%=chkReturn%>>Return</TD>
		</TR>
		<TR>
			<TD align="right" valign="top" class="titleFont">Default Route for Auto Escalate :</TD>
			<TD width="5"></TD>
			<TD class="titleFontleft" colspan="2"><INPUT type="radio" name="defaultRadio" id="defaultRadio" value="Y" <%=chkYes%>>Yes
			 <INPUT type="radio" name="defaultRadio" id="defaultRadio" value="N" <%=chkNo%>>No</TD>
		</TR>
	</TBODY>
	</TABLE
</FORM>
</DIV>
</BODY>
</HTML>
